<extend file='resource/view/mobile'/>
<block name="title">地址管理 - HDCMS开源免费三网系统</block>
<block name="content">
    <nav class="navbar navbar-default navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <a class="navbar-brand" href="{{web_url('entry/home')}}" style="position: absolute;">
                    <i class="fa fa-chevron-left"></i>
                </a>
                <p class="navbar-text navbar-right text-center">地址管理</p>
            </div>
        </div>
    </nav>
    <div style="height: 60px"></div>
    <foreach from="$data" value="$d">
        <div class="panel panel-default">
            <div class="panel-heading">
                <div class="user">
                    <span class="username">{{$d['username']}}</span>
                    <span class="tel">{{$d['mobile']}}</span>
                </div>
                <div class="address">
                    {{$d['province']}}{{$d['city']}}{{$d['district']}}{{$d['address']}}
                </div>
            </div>
            <div class="panel-body">
                <div class="pull-left">
                    <if value="$d['isdefault']">
                        <i class="fa fa-check-circle"></i> 默认地址
                        <else/>
                        <label>
                            <input type="radio" name="isdefault" value="{{$d['id']}}"> 默认地址
                        </label>
                    </if>

                </div>
                <div class="pull-right">
                    <a href="{{web_url('address/post',['id'=>$d['id']])}}"><i class="fa fa-pencil-square-o"></i> 编辑</a>
                    <a href="javascript:;" onclick="del({{$d['id']}})"><i class="fa fa-trash-o"></i> 删除</a>
                </div>
            </div>
        </div>
    </foreach>

    <div style="height: 50px;"></div>
    <button class="btn btn-danger btn-block btn-lg navbar-fixed-bottom">
        <a href="{{web_url('address/post')}}"><i class="fa fa-plus"></i> 新建地址</a>
    </button>
    <script>
        //设置默认地址
        $("[name='isdefault']").click(function () {
            var id = $(this).val();
            $.get("{{web_url('address/changeDefault')}}&id=" + id, function () {
                location.reload(true);
            })
        });
        //删除地址
        function del(id) {
            util.confirm('确定删除吗', function () {
                $.get("{{web_url('address/remove')}}&id=" + id, function () {
                    location.reload(true);
                })
            }, {width: ''})
        }
    </script>
    <style>
        body {
            background : #f5f5f5;
        }

        div.user {
            font-size     : 14px;
            margin-bottom : 5px;
        }

        div.address {
            font-size : 12px;
        }

        .panel {
            border-radius : 0px;
            border        : none;
        }

        .panel-default > .panel-heading {
            background : #ffffff;
        }

        .panel-body {
            padding   : 6px 15px;
            font-size : 12px;
        }

        .panel-body a {
            color : #999999;
        }

        .btn {
            border-radius : 0px;
        }

        .btn a {
            color : #ffffff;
        }
    </style>
</block>